﻿using AutoMapper;
using MediatR;
using Traceability.Commont.Domains;
using Traceability.Commont.Infrastructures.Interfaces;

namespace Traceability.Api.Applications.Permissionts
{
    public class PermissionsCreateHander : IRequestHandler<PermissionsCreateCommand, int>
    {
        private readonly IBateRepository<Permissions> permissions;
        private readonly IMapper mapper;

        public PermissionsCreateHander(IBateRepository<Permissions> permissions, IMapper mapper)
        {
            this.permissions = permissions;
            this.mapper = mapper;
        }

        public async Task<int> Handle(PermissionsCreateCommand request, CancellationToken cancellationToken)
        {
            Permissions info = mapper.Map<Permissions>(request);
            var res =await permissions.Add(info);
            return res;
        }
    }
}
